using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class CoinUpgradeItem
{
    public bool UpgradeFinish { get; private set; } = false;
    public string Key { get; private set; }
    public string Description { get; private set; }
    public int Price { get; private set; }
    public void Upgrade()
    {
        mOnUpgrade?.Invoke(this);
        UpgradeFinish = true;
        CoinUpgradeSystem.OnCoinUpgradeSystemChanged.Trigger();
    }
    public bool ConditionCheck()
    {
        if (mCondition != null)
        {
            return !UpgradeFinish && mCondition.Invoke(this);
        }
        return !UpgradeFinish;

    }
    private Action<CoinUpgradeItem> mOnUpgrade;
    private Func<CoinUpgradeItem, bool> mCondition;

    public CoinUpgradeItem WithKey(string key)
    {
        Key = key;
        return this;
    }
    public CoinUpgradeItem WithDescription(string description)
    {
        Description = description;
        return this;
    }
    public CoinUpgradeItem WithPrice(int price)
    {
        Price = price;
        return this;
    }
    public CoinUpgradeItem OnUpgrade(Action<CoinUpgradeItem> OnUpgrade)
    {
        mOnUpgrade = OnUpgrade;
        return this;
    }
    public CoinUpgradeItem Condition(Func<CoinUpgradeItem, bool> condition)
    {
        mCondition = condition;
        return this;
    }
}
